{extend name="common@base" /}

{block name="body_body"}
        {if condition="isset($articles)"}
        {volist name="articles" id="article"}
        
            <div class="panel panel-default">
                <div class="panel-heading"><div class="row"><div class="col-md-9"><a href="{$_form.article_detail}{$article->articleId}">{$article->title}</a></div> <div class="col-md-3">{$article->createTime}</div></div></div>
                <div class="panel-body">{$article->tabloid}</div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-md-2">
                            <a href="{$_form.article_laud}{$article->articleId}"  data-toggle="tooltip" data-placement="top" title="点赞数"  style="color: black;" class="laud">
                                <span class="fi-thumb-up"><span class="badge badge-warning">{$article->countLauds}</span></span>
                            </a>
                        </div>
                        <div class="col-md-8">

                        </div>
                        <div class="col-md-2">
                            <div style="float: left"><span  data-toggle="tooltip" data-placement="top" title="阅读数" class="fi-book"><span class="badge badge-light">{$article->countBrowses}</span></span></div>
                            <div style="float: right"><a href="{$_form.user_article}{$article->user->userId}">{$article->user->nickname}</a></div>
                        </div>
                    </div>
                </div>
            </div>
        {/volist}
        {/if}

<script>
    $(".laud").on('click',function () {
        var that = $(this);
        $.ajax({
            url:this.href,
            success:function (data) {
                var d = JSON.parse(data);
                if (d.msg == 0){
                    alert(d.info);
                }else{
                    that.find('.badge').text(parseInt(d.data.Lauds));
                }
            },error:function () {
                alert('服务器异常，请稍后再试。');
            }
        });
        return false;
    });
</script>
{/block}

{block name="body_sidebar"}
    <div class="col">
        <div class="panel panel-default">
            <div class="panel-heading">热门文章</div>
            <div class="panel-body">
            {if condition="isset($hotArticles)"}
                {volist name="hotArticles" id="article"}
                    <p><a href="{$_form.article_detail}{$article->articleId}">《{$article->title}》</a>——{$article->user->nickname}</p>
                {/volist}
            {/if}
            </div>
        </div>
    </div>
{/block}